class Solution:
    def findMedianSortedArrays(self, nums1, nums2):
        """
        :type nums1: List[int]
        :type nums2: List[int]
        :rtype: float
        """
        array = []
        maxl = len(nums1) + len(nums2)
        i, j= 0, 0
        while i < len(nums1) or j <len(nums2) and len(array) <= maxl//2 + 1:
            if i >= len(nums1):
                array = array+nums2[j:]
                break
            if j >= len(nums2):
                array = array+nums1[i:]
                break
            if nums1[i] < nums2[j]:
                array.append(nums1[i])
                i += 1
            else:
                array.append(nums2[j])
                j += 1
        if maxl%2 == 0:
            mid = (array[maxl//2 - 1] + array[maxl//2])/2
        else:
            mid = array[maxl//2]
        return mid